package offer.diff;

/**
 * @author DengYuan2
 * @create 2021-03-05 20:20
 */
public class n_16 {
    public static void main(String[] args) {
        n_16 n = new n_16();
        double res = n.myPow(2, 2);
        System.out.println(res);
    }

    public double myPow(double x, int n) {
        double res = 1;
        for (int i = n; i!=0; i /= 2) {
            if (i % 2 != 0) {
                res *= x;
            }
            x*=x;
        }
        return n<0?1/res:res;
    }
}
